package org.ruoyi.chat.service.chat.impl;

import org.ruoyi.chat.service.chat.ISseService;
import org.ruoyi.common.chat.handler.WebSocketMessageHandler;
import org.ruoyi.common.chat.request.ChatRequest;
import org.springframework.stereotype.Service;
import org.springframework.web.socket.WebSocketSession;

import java.util.function.Consumer;

/**
 * @author eric
 */
@Service
public class WebSocketMessageHandlerImpl implements WebSocketMessageHandler {

    private final ISseService sseService;

    public WebSocketMessageHandlerImpl(ISseService sseService) {
        this.sseService = sseService;
    }

    @Override
    public void handleWebSocketChat(ChatRequest chatRequest, WebSocketSession session, Consumer<String> messageConsumer) {
        sseService.sseChat(chatRequest, session, null);
    }
}
